package com.zero.youxiao.dao;


import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.zero.basic.dao.DefaultBaseDao;
import com.zero.basic.dao.HqlQueryBaseDao;
import com.zero.basic.dao.SqlListBaseDao;
import com.zero.basic.dao.SqlUpdateBaseDao;
import com.zero.mms.model.Menu;
import com.zero.mms.model.UserAccount;
import com.zero.youxiao.dto.MenuDto;

@Repository("menuDao")
@Transactional()
public class DeMenuDaoImpl extends DefaultBaseDao<Menu> implements
		MenuDao {

	@Inject
	private HqlQueryBaseDao<?> hqlQueryBaseDao;
	
	@Inject
	private SqlListBaseDao<?> sqlListBaseDao;

	@Override
	public List<MenuDto> getMenuTree() {
		try {
			if(sqlListBaseDao == null)
				System.out.println("dsads");
			String sql = "SELECT m.menu_id as id,m.menu_icon as icon,m.menu_name as name,m.menu_url as link,m.parent_id as parent "
					+ "FROM t_menu m";
			List<MenuDto> menuDtos = sqlListBaseDao.listBySql(sql, MenuDto.class, false, true);
			return menuDtos;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
